package com.czwx.bee.business.manager.modular.statistics.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @Author:wiki
 * @Date:Create in 2018/7/5 0005 下午 2:56
 */
@ApiModel(value="ConversionModel",description="转换率对象")
@AllArgsConstructor
@NoArgsConstructor
@Data
public class ConversionModel {

    @ApiModelProperty(value="日期")
    @JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8")
    private Date date;

    @ApiModelProperty(value="注册人数")
    private Long registNum;

    @ApiModelProperty(value="完善个人信息")
    private Long idStateNum;

    @ApiModelProperty(value="个人信息总数")
    private Long idStateTotal;

    @ApiModelProperty(value="个人信息比率")
    private String idStatePercent;

    @ApiModelProperty(value="完善紧急联系人")
    private Long contactNum;

    @ApiModelProperty(value="完善紧急联系人")
    private Long contactTotal;

    @ApiModelProperty(value="联系人比率")
    private String contactPercent;

    @ApiModelProperty(value="完善手机运营商")
    private Long phoneNum;

    @ApiModelProperty(value="完善手机运营商")
    private Long phoneTotal;

    @ApiModelProperty(value="运营商比率")
    private String phonePercent;

    @ApiModelProperty(value="网银信用卡")
    private Long creditCardNum;

    @ApiModelProperty(value="网银信用卡")
    private Long creditCardTotal;

    @ApiModelProperty(value="网银比率")
    private String creditCardPercent;

    @ApiModelProperty(value="银行卡")
    private Long bankCardNum;

    @ApiModelProperty(value="银行卡")
    private Long bankCardTotal;

    @ApiModelProperty(value="银行卡比率")
    private String bankCardPercent;

    @ApiModelProperty(value="申请授信")
    private Long applyForCreditNum;

    @ApiModelProperty(value="授信比率")
    private String applyForCreditPercent;

    @ApiModelProperty(value="通过授信笔数")
    private Long passCreditPassNum;

    @ApiModelProperty(value="通过授信比率")
    private String passCreditPercent;

    @ApiModelProperty(value="人工复审通过放款")
    private Long personReviewNum;

    @ApiModelProperty(value="人审通过率")
    private String personReviewPercent;

    public String getIdStatePercent() {
        if(idStateNum>0&&idStateTotal>0){
            Double percent=Double.valueOf(idStateNum)/Double.valueOf(idStateTotal)*100;
            BigDecimal bg = new BigDecimal(percent);
            percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
            return this.idStatePercent=percent+"%";
        }
        return  "0%";
    }

    public String getContactPercent() {
        if(contactNum>0&&contactTotal>0){
            Double percent=Double.valueOf(contactNum)/Double.valueOf(contactTotal)*100;
            BigDecimal bg = new BigDecimal(percent);
            percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
            return this.contactPercent=percent+"%";
        }
        return  "0%";
    }

    public String getPhonePercent() {
        if(phoneNum>0&&phoneTotal>0){
            Double percent=Double.valueOf(phoneNum)/Double.valueOf(phoneTotal)*100;
            BigDecimal bg = new BigDecimal(percent);
            percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
            return this.phonePercent=percent+"%";
        }
        return  "0%";
    }

    public String getCreditCardPercent() {
        if(creditCardNum>0&&creditCardTotal>0){
            Double percent=Double.valueOf(creditCardNum)/Double.valueOf(creditCardTotal)*100;
            BigDecimal bg = new BigDecimal(percent);
            percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
            return this.creditCardPercent=percent+"%";
        }
        return  "0%";
    }

    public String getBankCardPercent() {
        if(phoneNum>0&&phoneTotal>0){
            Double percent=Double.valueOf(phoneNum)/Double.valueOf(phoneTotal)*100;
            BigDecimal bg = new BigDecimal(percent);
            percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
            return this.phonePercent=percent+"%";
        }
        return  "0%";
    }

    public String getApplyForCreditPercent() {
        if(applyForCreditNum>0&&registNum>0){
            Double percent=Double.valueOf(applyForCreditNum)/Double.valueOf(registNum)*100;
            BigDecimal bg = new BigDecimal(percent);
            percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
            return this.applyForCreditPercent=percent+"%";
        }
        return  "0%";
    }

    public String getPassCreditPercent() {
        if(passCreditPassNum>0&&applyForCreditNum>0){
            Double percent=Double.valueOf(passCreditPassNum)/Double.valueOf(applyForCreditNum)*100;
            BigDecimal bg = new BigDecimal(percent);
            percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
            return this.passCreditPercent=percent+"%";
        }
        return  "0%";
    }

    public String getPersonReviewPercent() {
        if(personReviewNum>0&&applyForCreditNum>0){
            Double percent=Double.valueOf(personReviewNum)/Double.valueOf(applyForCreditNum)*100;
            BigDecimal bg = new BigDecimal(percent);
            percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
            return this.personReviewPercent=percent+"%";
        }
        return  "0%";
    }
}
